package com.kusen.village.raise.controller;

import com.kusen.village.raise.entity.ProductAttr;
import com.kusen.village.raise.service.ProductAttrService;
import com.kusen.village.raise.util.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @description: 商品属性的控制层
 * @author: ghl
 * @create: 2021-12-04 21:17
 **/
@Slf4j
@RestController
@RequestMapping("/attr")
public class ProductAttrController {
    @Autowired
    private ProductAttrService productAttrService;

    /**
     * 获取商品属性数据
     *
     * @param pid
     * @return
     */
    @GetMapping("/getProductAttr")
    public Map<String, Object> getProductAttr(Integer pid) {
        List<ProductAttr> result = productAttrService.getProductAttrList(pid);
        Map<String, Object> map = new HashMap<>();
        map.put("result", result);
        return R.ok().put("data", map).put("code", 200);
    }

}
